Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

app/src/main/java/com/geeksville/mesh/repository/radio/BleError.kt 78274c792318331b11ab64cd28e58e829875b8c2 (78274c79) Text, 6.58 KB

T8b949e/*
* Copyright (c) 2025 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

Tff7b72package T7ee787com.geeksville.mesh.repository.radio

Tff7b72import T7ee787com.geeksville.mesh.service.RadioNotConnectedException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.client.exception.BluetoothUnavailableException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.client.exception.ConnectionFailedException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.client.exception.InvalidAttributeException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.client.exception.OperationFailedException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.client.exception.PeripheralNotConnectedException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.client.exception.ScanningException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.client.exception.ValueDoesNotMatchException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.core.ConnectionState
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.core.exception.BluetoothException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.core.exception.GattException
Tff7b72import T7ee787no.nordicsemi.kotlin.ble.core.exception.ManagerClosedException

T8b949e/**
* Represents specific BLE failures, modeled after the iOS implementation's AccessoryError. This allows for more
* granular error handling and intelligent reconnection strategies.
*/
Tff7b72sealed Tff7b72class T56d364BleErrorTb4b4b4(Tff7b72val Te6edf3messageTb4b4b4: Tffa657StringTb4b4b4, Tff7b72val Te6edf3shouldReconnectTb4b4b4: Tffa657BooleanTb4b4b4) Tb4b4b4{

T8b949e/**
* An error indicating that the peripheral was not found. This is a non-recoverable error and should not trigger a
* reconnect.
*/
Tff7b72data Tff7b72object T56d364PeripheralNotFound Tb4b4b4: Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffPeripheral not foundTa5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72falseTb4b4b4)

T8b949e/**
* An error indicating a failure during the connection attempt. This may be recoverable, so a reconnect attempt is
* warranted.
*/
Tff7b72class T56d364ConnectionFailedTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3ThrowableTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffConnection failed: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/**
* An error indicating a failure during the service discovery process. This may be recoverable, so a reconnect
* attempt is warranted.
*/
Tff7b72class T56d364DiscoveryFailedTb4b4b4(Te6edf3messageTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4: Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffDiscovery failed: Tffd700$Te6edf3messageTa5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/**
* An error indicating a disconnection initiated by the peripheral. This may be recoverable, so a reconnect attempt
* is warranted.
*/
Tff7b72class T56d364DisconnectedTb4b4b4(Te6edf3reasonTb4b4b4: Te6edf3ConnectionStateTb4b4b4.Te6edf3DisconnectedTb4b4b4.Te6edf3ReasonTff7b72?Tb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffDisconnected: Tffd700${Te6edf3reason Tff7b72?: Ta5d6ff"Te6edf3Unknown Te6edf3reasonTa5d6ff"Tffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/**
* Wraps a generic GattException. The reconnection strategy depends on the nature of the Gatt error.
*
* @param exception The underlying GattException.
*/
Tff7b72class T56d364GattErrorTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3GattExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffGatt exception: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/**
* Wraps a generic BluetoothException. The reconnection strategy depends on the nature of the Bluetooth error.
*
* @param exception The underlying BluetoothException.
*/
Tff7b72class T56d364BluetoothErrorTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3BluetoothExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffBluetooth exception: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/** The BLE manager was closed. This is a non-recoverable error. */
Tff7b72class T56d364ManagerClosedTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3ManagerClosedExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffManager closed: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72falseTb4b4b4)

T8b949e/** A BLE operation failed. This may be recoverable. */
Tff7b72class T56d364OperationFailedTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3OperationFailedExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffOperation failed: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/** An invalid attribute was used. This is a non-recoverable error. */
Tff7b72class T56d364InvalidAttributeTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3InvalidAttributeExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffInvalid attribute: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72falseTb4b4b4)

T8b949e/** An error occurred while scanning for devices. This may be recoverable. */
Tff7b72class T56d364ScanningTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3ScanningExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffScanning error: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/** Bluetooth is unavailable on the device. This is a non-recoverable error. */
Tff7b72class T56d364BluetoothUnavailableTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3BluetoothUnavailableExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffBluetooth unavailable: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72falseTb4b4b4)

T8b949e/** The peripheral is not connected. This may be recoverable. */
Tff7b72class T56d364PeripheralNotConnectedTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3PeripheralNotConnectedExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffPeripheral not connected: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/** A value did not match what was expected. This may be recoverable. */
Tff7b72class T56d364ValueDoesNotMatchTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3ValueDoesNotMatchExceptionTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffValue does not match: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

T8b949e/** A generic error for other exceptions that may occur. */
Tff7b72class T56d364GenericErrorTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3ThrowableTb4b4b4) Tb4b4b4:
Te6edf3BleErrorTb4b4b4(Ta5d6ff"Ta5d6ffAn unexpected error occurred: Tffd700${Te6edf3exceptionTb4b4b4.Te6edf3messageTffd700}Ta5d6ff"Tb4b4b4, Te6edf3shouldReconnect Tff7b72= Tff7b72trueTb4b4b4)

Tff7b72companion Tff7b72object Tb4b4b4{
Tff7b72fun Td2a8fffromTb4b4b4(Te6edf3exceptionTb4b4b4: Te6edf3ThrowableTb4b4b4)Tb4b4b4: Te6edf3BleError Tff7b72= Tff7b72when Tb4b4b4(Te6edf3exceptionTb4b4b4) Tb4b4b4{
Tff7b72is Te6edf3GattException Tff7b72-Tff7b72> Tb4b4b4{
Tff7b72when Tb4b4b4(Te6edf3exceptionTb4b4b4) Tb4b4b4{
Tff7b72is Te6edf3ConnectionFailedException Tff7b72-Tff7b72> Te6edf3ConnectionFailedTb4b4b4(Te6edf3exceptionTb4b4b4)
Tff7b72is Te6edf3PeripheralNotConnectedException Tff7b72-Tff7b72> Te6edf3PeripheralNotConnectedTb4b4b4(Te6edf3exceptionTb4b4b4)
Tff7b72is Te6edf3OperationFailedException Tff7b72-Tff7b72> Te6edf3OperationFailedTb4b4b4(Te6edf3exceptionTb4b4b4)
Tff7b72is Te6edf3ValueDoesNotMatchException Tff7b72-Tff7b72> Te6edf3ValueDoesNotMatchTb4b4b4(Te6edf3exceptionTb4b4b4)
Tff7b72else Tff7b72-Tff7b72> Te6edf3GattErrorTb4b4b4(Te6edf3exceptionTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tff7b72is Te6edf3BluetoothException Tff7b72-Tff7b72> Tb4b4b4{
Tff7b72when Tb4b4b4(Te6edf3exceptionTb4b4b4) Tb4b4b4{
Tff7b72is Te6edf3BluetoothUnavailableException Tff7b72-Tff7b72> Te6edf3BluetoothUnavailableTb4b4b4(Te6edf3exceptionTb4b4b4)
Tff7b72is Te6edf3InvalidAttributeException Tff7b72-Tff7b72> Te6edf3InvalidAttributeTb4b4b4(Te6edf3exceptionTb4b4b4)
Tff7b72is Te6edf3ScanningException Tff7b72-Tff7b72> Te6edf3ScanningTb4b4b4(Te6edf3exceptionTb4b4b4)
Tff7b72else Tff7b72-Tff7b72> Te6edf3BluetoothErrorTb4b4b4(Te6edf3exceptionTb4b4b4)
Tb4b4b4}
Tb4b4b4}

Tff7b72is Te6edf3RadioNotConnectedException Tff7b72-Tff7b72> Te6edf3PeripheralNotFound
Tff7b72is Te6edf3ManagerClosedException Tff7b72-Tff7b72> Te6edf3ManagerClosedTb4b4b4(Te6edf3exceptionTb4b4b4)
Tff7b72else Tff7b72-Tff7b72> Te6edf3GenericErrorTb4b4b4(Te6edf3exceptionTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s